package tpf.designer.pattern.course5.structure_pattern2.flyweight_13.simple_2;

import org.junit.Test;

import static javafx.scene.input.KeyCode.F;

/**
 * Client对象，通常会维持一个对flyweight的引用，
 * 计算或存储一个或多个flyweight的外部状态
 */
public class Client {
    @Test
    public void testSimple2(){
        //创建一个享元工厂
        FlyweightFactory flyweightFactory = new FlyweightFactory();
        //向享元工厂对象请求一个内蕴状态为1的享元对象
        Flyweight flyweight = flyweightFactory.getFlyweight("1");
        //以参量的形式传入一个外蕴状态
        flyweight.operation("_1");

        flyweight = flyweightFactory.getFlyweight("2");
        flyweight.operation("_2");

        flyweight = flyweightFactory.getFlyweight("1");
        flyweight.operation("_3");



        Flyweight f = new UnsharedConcreteFlyweight("Unshared");
        f.operation("ExtrinsicState");

        flyweightFactory.checkFlyweight();

    }
}
